package com.hethongviet.job.models;

import android.app.Activity;
import com.google.android.maps.GeoPoint;
import com.hethongviet.job.R;
import com.hethongviet.job.helpers.JSONAttributes;

public class Task
{

	private String id = null;
	private long idDB = -1;
	private String code = null;
	private String name = null;
	private String projectCode = null;
	private String projectId = null;
	private String projectName = null;
	private String worker = null;
	private String dateCreated = null;
	private String dateRequireStart = null;
	private String dateRequireFinish = null;
	private GeoPoint workerGPSGeoPointStart = null;
	private GeoPoint workerGPSGeoPointFinish = null;
	private String description = null;
	private String note = null;
	private String guideText = null;

	private FileGeneral fileAttachment = null;

	private FileImage imageFileStart = null;
	private FileImage imageFileFinish = null;

	private String importantLevel = null;
	private String dateActualStart = null;
	private String dateActualFinish = null;

	private int status = -1;

	private boolean isViewImageStart = true;

	private boolean isSyncDataStart = true;
	private boolean isSyncDataFinish = true;

	/* For Status */
	public static final int STATUS_JUST_CREATE = 0;
	public static final int STATUS_DELAY_START = STATUS_JUST_CREATE + 1;
	public static final int STATUS_DELAY_FINISH = STATUS_DELAY_START + 1;
	public static final int STATUS_IN_PROCESS = STATUS_DELAY_FINISH + 1;
	public static final int STATUS_FINISH = STATUS_IN_PROCESS + 1;

	public Task()
	{
	}

	public Task clone()
	{
		Task task = new Task();
		task.id = id;
		task.code = code;
		task.name = name;
		task.projectCode = projectCode;
		task.projectId = projectId;
		task.projectName = projectName;
		task.worker = worker;
		task.dateCreated = dateCreated;
		task.dateRequireStart = dateRequireStart;
		task.dateRequireFinish = dateRequireFinish;
		if (workerGPSGeoPointStart != null)
			task.workerGPSGeoPointStart = new GeoPoint(
					workerGPSGeoPointStart.getLatitudeE6(),
					workerGPSGeoPointStart.getLongitudeE6());
		if (workerGPSGeoPointFinish != null)
			task.workerGPSGeoPointFinish = new GeoPoint(
					workerGPSGeoPointFinish.getLatitudeE6(),
					workerGPSGeoPointFinish.getLongitudeE6());
		task.description = description;
		task.imageFileFinish = imageFileFinish;
		task.imageFileStart = imageFileStart;
		task.fileAttachment = fileAttachment;
		task.importantLevel = importantLevel;
		task.dateActualStart = dateActualStart;
		task.dateActualFinish = dateActualFinish;
		task.note = note;
		task.status = status;
		return task;
	}

	public boolean isStarted()
	{
		return status != STATUS_JUST_CREATE && status != STATUS_DELAY_START;
	}

	public boolean isDelay()
	{
		return status == STATUS_DELAY_START || status == STATUS_DELAY_FINISH;
	}

	public boolean isFinished()
	{
		return status == STATUS_FINISH;
	}

	public boolean isViewImageStart()
	{
		return isViewImageStart;
	}

	public int getStatusColor(Activity activity)
	{
		if (status == STATUS_DELAY_FINISH)
		{
			return activity.getResources().getColor(
					R.color.colorTaskDelayFinish);
		}
		else if (status == STATUS_DELAY_START)
		{
			return activity.getResources().getColor(R.color.colorTaskDelayStart);
		}
		else if (status == STATUS_FINISH)
		{
			return activity.getResources().getColor(R.color.colorTaskFinish);
		}
		else if (status == STATUS_IN_PROCESS)
		{
			return activity.getResources().getColor(R.color.colorTaskInProcess);
		}
		return activity.getResources().getColor(R.color.colorTaskJustCreate);
	}

	public static int getStatusColor(Activity activity, int status)
	{
		if (status == STATUS_DELAY_FINISH)
		{
			return activity.getResources().getColor(
					R.color.colorTaskDelayFinish);
		}
		else if (status == STATUS_DELAY_START)
		{
			return activity.getResources().getColor(R.color.colorTaskDelayStart);
		}
		else if (status == STATUS_FINISH)
		{
			return activity.getResources().getColor(R.color.colorTaskFinish);
		}
		else if (status == STATUS_IN_PROCESS)
		{
			return activity.getResources().getColor(R.color.colorTaskInProcess);
		}
		return activity.getResources().getColor(R.color.colorTaskJustCreate);
	}

	public static int getStatusColor(Activity activity, String statusString)
	{
		if (statusString.equalsIgnoreCase(JSONAttributes.STATUS_DELAY_FINISH))
		{
			return activity.getResources().getColor(
					R.color.colorTaskDelayFinish);
		}
		else if (statusString.equalsIgnoreCase(JSONAttributes.STATUS_DELAY_START))
		{
			return activity.getResources().getColor(R.color.colorTaskDelayStart);
		}
		else if (statusString.equalsIgnoreCase(JSONAttributes.STATUS_FINISH))
		{
			return activity.getResources().getColor(R.color.colorTaskFinish);
		}
		else if (statusString.equalsIgnoreCase(JSONAttributes.STATUS_IN_PROCESS))
		{
			return activity.getResources().getColor(R.color.colorTaskInProcess);
		}
		return activity.getResources().getColor(R.color.colorTaskJustCreate);
	}

	public String getStatusString(Activity activity)
	{
		if (status == STATUS_DELAY_FINISH)
		{
			return activity.getString(R.string.textTaskStatusDelayFinish);
		}
		else if (status == STATUS_DELAY_START)
		{
			return activity.getString(R.string.textTaskStatusDelayStart);
		}
		else if (status == STATUS_FINISH)
		{
			return activity.getString(R.string.textTaskStatusFinish);
		}
		else if (status == STATUS_IN_PROCESS)
		{
			return activity.getString(R.string.textTaskStatusInProgress);
		}
		return activity.getString(R.string.textTaskStatusJustCreate);
	}

	public String getCode()
	{
		return code;
	}

	public void setCode(String code)
	{
		this.code = code;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getWorker()
	{
		return worker;
	}

	public void setWorker(String worker)
	{
		this.worker = worker;
	}

	public String getDateCreated()
	{
		return dateCreated;
	}

	public void setDateCreated(String dateCreated)
	{
		this.dateCreated = dateCreated;
	}

	public String getProjectCode()
	{
		return projectCode;
	}

	public void setProjectCode(String projectCode)
	{
		this.projectCode = projectCode;
	}

	public GeoPoint getWorkerGPSGeoPointStart()
	{
		return workerGPSGeoPointStart;
	}

	public void setWorkerGPSGeoPointStart(GeoPoint workerGPSGeoPoint)
	{
		this.workerGPSGeoPointStart = workerGPSGeoPoint;
	}

	public String getDescription()
	{
		return description;
	}

	public void setDescription(String description)
	{
		this.description = description;
	}

	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public String getProjectId()
	{
		return projectId;
	}

	public void setProjectId(String projectId)
	{
		this.projectId = projectId;
	}

	public String getProjectName()
	{
		return projectName;
	}

	public void setProjectName(String projectName)
	{
		this.projectName = projectName;
	}

	public String getDateRequireStart()
	{
		return dateRequireStart;
	}

	public void setDateRequireStart(String dateRequireStart)
	{
		this.dateRequireStart = dateRequireStart;
	}

	public String getDateRequireFinish()
	{
		return dateRequireFinish;
	}

	public void setDateRequireFinish(String dateRequireFinish)
	{
		this.dateRequireFinish = dateRequireFinish;
	}

	public String getImportantLevel()
	{
		return importantLevel;
	}

	public void setImportantLevel(String importantLevel)
	{
		this.importantLevel = importantLevel;
	}

	public String getDateActualStart()
	{
		return dateActualStart;
	}

	public void setDateActualStart(String dateActualStart)
	{
		this.dateActualStart = dateActualStart;
	}

	public String getDateActualFinish()
	{
		return dateActualFinish;
	}

	public void setDateActualFinish(String dateActualFinish)
	{
		this.dateActualFinish = dateActualFinish;
	}

	public String getNote()
	{
		return note;
	}

	public void setNote(String note)
	{
		this.note = note;
	}

	public int getStatus()
	{
		return status;
	}

	public void setStatus(int status)
	{
		this.status = status;
	}

	public GeoPoint getWorkerGPSGeoPointFinish()
	{
		return workerGPSGeoPointFinish;
	}

	public void setWorkerGPSGeoPointFinish(GeoPoint workerGPSGeoPointFinish)
	{
		this.workerGPSGeoPointFinish = workerGPSGeoPointFinish;
	}

	public FileImage getImageFileStart()
	{
		return imageFileStart;
	}

	public void setImageFileStart(FileImage imageFileStart)
	{
		this.imageFileStart = imageFileStart;
	}

	public FileImage getImageFileFinish()
	{
		return imageFileFinish;
	}

	public void setImageFileFinish(FileImage imageFileFinish)
	{
		this.imageFileFinish = imageFileFinish;
	}

	public void setViewImageStart(boolean isViewImageStart)
	{
		this.isViewImageStart = isViewImageStart;
	}

	public long getIdDB()
	{
		return idDB;
	}

	public void setIdDB(long idDB)
	{
		this.idDB = idDB;
	}

	public String getGuideText()
	{
		return guideText;
	}

	public void setGuideText(String guideText)
	{
		this.guideText = guideText;
	}

	public FileGeneral getFileAttachment()
	{
		return fileAttachment;
	}

	public void setFileAttachment(FileGeneral fileAttachment)
	{
		this.fileAttachment = fileAttachment;
	}

	public boolean isSyncDataStart()
	{
		return isSyncDataStart;
	}

	public void setSyncDataStart(boolean isSyncDataStart)
	{
		this.isSyncDataStart = isSyncDataStart;
	}

	public boolean isSyncDataFinish()
	{
		return isSyncDataFinish;
	}

	public void setSyncDataFinish(boolean isSyncDataFinish)
	{
		this.isSyncDataFinish = isSyncDataFinish;
	}
}
